#include <iostream>
#include <vector>

int main() {
    int n;
    
    std::cin >> n;
    std::vector<int> teams_of_schools(n);
    
    for (auto & count : teams_of_schools) {
        std::cin >> count;
    }

    std::vector<std::vector<int>> assignments_of_schools(n);

    std::vector<int> active_school_idx;
    active_school_idx.reserve(n);

    for (int idx = 0; idx < assignments_of_schools.size(); ++idx) {
        assignments_of_schools[idx].reserve(teams_of_schools[idx] * 10);
        active_school_idx.push_back(idx);
    }

    int last_number = 0;

    while (active_school_idx.size() > 1) {
        auto it = active_school_idx.begin();
        while (it != active_school_idx.end()) {
            auto idx = *it;
            assignments_of_schools[idx].push_back(++last_number);
            if (assignments_of_schools[idx].size() == teams_of_schools[idx] * 10) {
                it = active_school_idx.erase(it);
            }
            else ++it;
        }
    }
    
    if (active_school_idx.size() == 1) {
        auto idx = active_school_idx.front();
        if (assignments_of_schools[idx].empty()) {  // Only one school exists
            last_number = -1;
        }
        else if (assignments_of_schools[idx].back() != last_number) {  // Last filled school is not the last one to fill
            last_number -= 1;
        }
        while (assignments_of_schools[idx].size() < teams_of_schools[idx] * 10) {
            last_number += 2;
            assignments_of_schools[idx].push_back(last_number);
        }
    }

    for (int i = 0; i < assignments_of_schools.size(); ++i) {
        std::cout << "#" << i + 1 << "\n";
        auto cnt = 0;
        for (auto val : assignments_of_schools[i]) {
            std::cout << val;
            cnt += 1;
            if (cnt == 10) { cnt = 0; std::cout << "\n"; }
            else { std::cout << " "; }
        }
    }
}
